<template>
  <view class="container">

    <!-- 通知列表 -->
    <scroll-view class="notice-list" scroll-y>
      <!-- 通知项模板 -->
      <view 
		  v-for="(item,index) in noticeList" 
		  :key="index"
		  class="notice-item">
        
        <!-- 文字内容 -->
        <view class="text-content">
			
          <view class="notice-header">
            <text class="notice-title">设备状态</text>
            <text class="notice-time">{{ item.checkTime }}</text>
          </view>
          <text class="notice-content">
            {{item.batteryStatus}}
          </text>
        </view>
      </view>

    </scroll-view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { onLoad } from '@dcloudio/uni-app'
import { getCheckBattery } from '@/api/common.js'
const noticeList = ref([]);
const timeData = ref('')

const loadNotice = () => {
	const userInfo = uni.getStorageSync('userInfo') || {};
	// console.log(userInfo);
	const userId = userInfo.id
	// console.log(userId);
	getCheckBattery(userId)
	.then((res) => {
		console.log(res.data,'低电量提醒');
		noticeList.value = res.data;
		// console.log(noticeList.value);
	})
}

onLoad(()=>{
	loadNotice()
})
</script>

<style lang="scss" scoped>
.container {
  background-color: #f5f5f5;
  // min-height: 100vh;
}


.notice-list {
	margin-top: 50rpx;
	width: 700rpx;
  padding: 20rpx 30rpx;
  height: calc(100vh - 100rpx);
}

.notice-item {
  background-color: #fff;
  border-radius: 16rpx;
  padding: 20rpx;
  margin-bottom: 24rpx;
  display: flex;
  align-items: flex-start;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);

  /* 图片容器样式 */
  // .image-container {
  //   width: 120rpx;
  //   height: 120rpx;
  //   margin-right: 20rpx;
  //   flex-shrink: 0;
    
  //   .notice-image {
  //     width: 100%;
  //     height: 100%;
  //     border-radius: 8rpx;
  //     background-color: #eee;
  //   }

  //   .image-placeholder {
  //     width: 100%;
  //     height: 100%;
  //     background-color: #f5f5f5;
  //     border-radius: 8rpx;
  //   }
  // }

  .text-content {
    flex: 1;
    min-width: 0;
  }

  .notice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16rpx;
  }

  .notice-title {
    font-size: 32rpx;
    color: #333;
    font-weight: 500;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .notice-time {
    font-size: 24rpx;
    color: #999;
  }

  .notice-content {
    font-size: 28rpx;
    color: #666;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
}
</style>